import 'package:flutter/material.dart';
import 'package:x3_base_package/x3_base_package.dart';
import 'package:x3_business_core/business_customer/less_components/business_customer_details_dynamic_list.dart';

class BusinessCustomerDetailsBehavior extends StatefulWidget {
  static String sName = 'BusinessCustomerDetailsBehavior';

  @override
  _BusinessCustomerDetailsBehaviorState createState() => _BusinessCustomerDetailsBehaviorState();
}

class _BusinessCustomerDetailsBehaviorState extends State<BusinessCustomerDetailsBehavior> {
  final BaseRefreshController _controller = BaseRefreshController();

  ///顶部提示文字
  List<Map<String, dynamic>> _tipTextAtTheTop = [
    {'互动': '互动动态：会员的微信足迹'},
    {'服务': '服务动态：导购对会员的维护服务'},
    {'消费': '消费动态：会员购买/退换记录'},
  ];

  @override
  Widget build(BuildContext context) {
    BaseHttpResponseModel argument = BaseRouterUtil.getArguments(context);
    return BaseScaffoldComponent(
      backGroundColor: Colors.white,
      title: argument.name.substring(1) + '动态',
      child: Column(
        children: [
          _buildCurrentPageDescription(argument.name.substring(1)),
          Expanded(
            child: Container(
              padding: EdgeInsets.symmetric(horizontal: 16, vertical: 10),
              child: BusinessCustomerDetailsDynamicList(
                service: argument.inputApi,
                controller: _controller,
              ),
            ),
          ),
        ],
      ),
    );
  }

  ///当前页面描述
  Widget _buildCurrentPageDescription(String tipKey) {
    int _index = _tipTextAtTheTop.indexWhere((element) => element.containsKey(tipKey));
    if (_index == -1) return Container();
    return Container(
      height: 40,
      color: Color(0xFFFFFEEF),
      padding: EdgeInsets.symmetric(horizontal: 16),
      child: Row(
        children: [
          Icon(BaseIconData.x3Description, size: 18, color: Color(0xFFFF8A00)),
          SizedBox(width: 2),
          Text(_tipTextAtTheTop[_index][tipKey], style: TextStyle(color: Color(0xFFFF8A00), fontSize: 12)),
        ],
      ),
    );
  }
}
